import 'package:flutter/material.dart';
import 'package:flutter_eve_plugin/constants/font_family.dart';
import 'package:flutter_eve_plugin/constants/font_weight.dart';
import 'package:flutter_eve_plugin/pages/main/actions.dart';
import 'package:flutter_eve_plugin/utils/image_util.dart';
import 'package:flutter_eve_plugin/utils/screen_util.dart';

AppBar buildArchivesAppBarTitle(String title) {
  return AppBar(
      backgroundColor: Colors.transparent,
      elevation: 0,
      title: Text(
        title,
        style: TextStyle(
            shadows: [
              BoxShadow(
                  color: Color(0x80000000),
                  offset: Offset(0, setRatio(2)),
                  blurRadius: setRatio(2))
            ],
            decorationColor: Color(0x80000000),
            color: Color(0xFFEFF0F8),
            fontFamily: FontFamily.PMZD,
            fontSize: setTextSp(18)),
      ),
      leading: Builder(
        builder: (BuildContext context) {
          return IconButton(
            icon: Image.asset(
              imageUtilYeXiu('main/icon_back3@3x'),
              width: setRatio(31),
              height: setRatio(28),
            ),
            onPressed: () {
              Navigator.canPop(context)
                  ? Navigator.pop(context)
                  : goBackNative();
            },
          );
        },
      ));
}

AppBar buildArchivesAppBar(
    int index, String title1, String title2, int gold,Function(int index) select) {

  return AppBar(
    backgroundColor: Colors.transparent,
    elevation: 0,
    title: _buildArchivesAppBarContent(index, title1, title2, select),
    actions: <Widget>[
      Container(
        margin: EdgeInsets.only(right: setRatio(10)),
        child: Center(
          child: Stack(
            overflow: Overflow.visible,
            children: <Widget>[
              Container(
                width: setRatio(96),
                height: setRatio(21),
                decoration: BoxDecoration(
                    image: DecorationImage(
                        image: AssetImage(
                            imageUtilYeXiu('main/icon_nav_right_bg@3x')))),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    SizedBox(
                      width: setRatio(5),
                    ),
                    Image.asset(
                      imageUtilYeXiu('main/icon_nav_right_coin@3x'),
                      width: setRatio(17),
                      height: setRatio(17),
                    ),
                    Text(
                      '$gold',
                      style: TextStyle(
                          decoration: TextDecoration.none,
                          fontFamily: FontFamily.PINGFANG,
                          fontWeight: FontWeightCustom.PF_Medium,
                          fontSize: setTextSp(10),
                          color: Color(0xFFFFFFFF)),
                    )
                  ],
                ),
              ),
              Positioned(
                right: 0,
                top: setRatio(-3),
                child: Image.asset(
                  imageUtilYeXiu('main/icon_nav_right_add@3x'),
                  width: setRatio(26),
                  height: setRatio(26),
                ),
              )
            ],
          ),
        ),
      )
    ],
    leading: Builder(
      builder: (BuildContext context) {
        return IconButton(
          icon: Image.asset(
            imageUtilYeXiu('main/icon_back3@3x'),
            width: setRatio(31),
            height: setRatio(28),
          ),
          onPressed: () {
            Navigator.canPop(context) ? Navigator.pop(context) : goBackNative();
          },
        );
      },
    ),
  );
}

Padding _buildArchivesAppBarContent(
    int index, String btn1, String btn2, Function(int index) select) {
  return Padding(
    padding: EdgeInsets.only(right: setRatio(10)),
    child: Row(
      mainAxisAlignment: MainAxisAlignment.spaceAround,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: <Widget>[
        GestureDetector(
          onTap: () {
            select(0);
          },
          child: Container(
            width: setRatio(54),
            height: setRatio(31),
            decoration: BoxDecoration(
              image: DecorationImage(
                  image: AssetImage(imageUtilYeXiu(index == 0
                      ? 'archives/icon_archives_select@3x'
                      : 'archives/icon_archives_no_select@3x'))),
            ),
            child: Center(
              child: Text(
                btn1,
                // shadow: Color(0x80000000),
                style: TextStyle(
                    letterSpacing: 2,
                    decoration: TextDecoration.none,
                    fontFamily: FontFamily.PMZD,
                    fontSize: setTextSp(16),
                    color: Color(0xFFEFF0F8)),
              ),
            ),
          ),
        ),
        GestureDetector(
          onTap: () {
            select(1);
          },
          child: Container(
            width: setRatio(54),
            height: setRatio(31),
            decoration: BoxDecoration(
              image: DecorationImage(
                  image: AssetImage(imageUtilYeXiu(index == 1
                      ? 'archives/icon_archives_select@3x'
                      : 'archives/icon_archives_no_select@3x'))),
            ),
            child: Center(
              child: Text(
                btn2,
                // shadow: Color(0x80000000),
                style: TextStyle(
                    letterSpacing: 2,
                    decoration: TextDecoration.none,
                    fontFamily: FontFamily.PMZD,
                    fontSize: setTextSp(16),
                    color: Color(0xFFEFF0F8)),
              ),
            ),
          ),
        ),
      ],
    ),
  );
}
